qrisp.QuantumCircuit.t_depth#

QuantumCircuit.t_depth(epsilon=None)[source]#

Estimates the T-depth of self. T-depth is an important metric for fault tolerant quantum computing, because T gates are expected to be the bottleneck in fault tolerant architectures.

According to this paper, the synthesis of an \(RZ(\phi)\) up to precision \(\epsilon\) requires \(3\text{log}_2(\frac{1}{\epsilon})\) T-gates.

Based on this formula, this method performs a conservative estimate of the T-depth of self.

Parameters:
epsilonfloat, optional

The precision up to which parametrized gates should be approximated. If not given, Qrisp will determine the parameter with the highest precision. For more information on this feature see the examples

Returns:
float

The estimated T-depth.

Examples

We create a QuantumCircuit and evaluate the T-depth:

>>> import numpy as np
>>> from qrisp import QuantumCircuit
>>> qc = QuantumCircuit(2)
>>> qc.t(0)
>>> qc.cx(0,1)
>>> qc.rx(2*np.pi*3/2**4, 1)
>>> qc.t_depth(epsilon = 2**-5)
16

In this example we execute a T-Gate on the 0-th qubit (T-depth : 1) followed by a CNOT gate (T-depth: 0) on qubits 0 and 1 and finally an RX gate.

The RX-Gate can be executed by using the decomposition

\[RX(\phi) = \text{H } \text{RZ}(\phi) \text{ H}\]

The T-depth of executing a parametrized RX gate is therefore the same as the parametrized RZ. To determine the T-depth of the RZ-gate, executed with precision \(2^{-5}\) we use the above formula:

\[\begin{split}\begin{align} \text{TDEPTH}(\text{RZ}(\phi), \epsilon = 2^-5) = 3 \text{log}_2(2^5)\\ &= 15 \end{align}\end{split}\]

We therefore arrive at 16.

Automatic precision determination

In the case of unknown precision, Qrisp assumes that every parameter in the circuit is of the form.

\[\phi = 2\pi\frac{m}{2^k}\]

Where \(m\) is an integer. Qrisp will then determine the parameter with the maximum \(k\) and set \(\epsilon = 2^{k_{max} +3}\).

>>> qc.t_depth()
22

In this circuit \(k_{max} = 4\) therefore, \(\epsilon = 2^{-7}\) implying the T-depth is 22.